extends "res://ui/msgBase/msgBase.gd"

var utils = globalData.infoDs["g_azurlaneUtils"]
var base = globalData.infoDs["g_azurlaneBase"]
var mainScript = load(self.get_script().get_path().get_base_dir() + "/azurMain.gd")

var lv = 0
var infos = jinJieData.infos
var maxLv = 4
func _ready():
	upInfo(jinJieData.ulokLv)
	if jinJieData.ulokLv >= 5:
		$NinePatchRect2.show()
	else :
		$NinePatchRect2.show()

func init():
	upInfo(jinJieData.ulokLv)
	popup()
	$NinePatchRect2.queue_free()

func _on_r_pressed():
	if lv >= maxLv:
		sys.newBaseMsg("提示", "这是暂时最高的等级。")
		return 
	if lv >= jinJieData.ulokLv:
		sys.newBaseMsg("提示", "你需要通关当前等级，才能解锁下一个等级。")
		return 
	lv += 1
	if lv > maxLv:lv = maxLv
	upInfo()

func _on_l_pressed():
	lv -= 1
	if lv < 0:lv = 0
	upInfo()

var lvInfos = [
	"初生萌新不怕虎","杀出新手村","你为什么这么熟练啊","你已经是大佬了，大胆的A上去吧","FBI Warning:这是最高难度，萌新慎入"
]
func upInfo(lv = null):
	if lv != null:
		self.lv = min(maxLv, lv)
	lv = self.lv
	$NinePatchRect / Control / lv.text = str(lv)
	$NinePatchRect / Control / info.text = lvInfos[lv]
	
func _on_Button_pressed():
	jinJieData.nowLv = lv
	queue_free()
	sys.get_node("../Control").queue_free()
	var main = preload("res://main.tscn").instance()
	sys.get_parent().add_child(main)
	utils.changeScript(main, mainScript)
	main.init()

	chaData.rndPoolRsl = chaData.rndPoolRal
	main.initSt()
	base.gameStart(true)

func _on_wjBtn_pressed():
	jinJieData.nowLv = 5
	queue_free()
	sys.get_node("../Control").queue_free()
	var main = preload("res://main.tscn").instance()
	sys.get_parent().add_child(main)
	main.init(1)
	
